#!/usr/bin/env python3.0

import curses
import curses.textpad

def main():
	# initialize curses.
	stdscr = curses.initscr()
	curses.cbreak()
	curses.noecho()
	stdscr.keypad(True)

	height = curses.LINES;
	width = curses.COLS;

	# it cannot receive multibyte characters.
	win = curses.newwin(height//2,width//2,5,10)
	win.refresh()

	#str = win.getstr()
	(y0,x0) = (0,0)
	(y1,x1) = (y0+1, x0)
	while True:
		ch = win.getch()
		if ch==ord('\n'):
			break
		win.addch(y0, x0, ch)
		(y0,x0) = win.getyx()
		win.addstr(y1+1, x1, "\{0:d}".format(ch))
		(y1,x1) = win.getyx()
		y1 -= 1

	curses.endwin()

	#print("you endered {0:s}".format(str.decode()))


main()
